# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=libmusicxml
pkgver=3.22
pkgrel=2
pkgdesc="Portable C++ library around the MusicXML format"
arch=(loong64 x86_64)
url="https://github.com/grame-cncm/libmusicxml"
license=(MPL2)
depends=(gcc-libs glibc)
makedepends=(cmake)
provides=(liblibmusicxml.so)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('31e7dcddfd471185f927c84369f4ae2b0a92354073368400d63e09a413dc2227bcc3b9124a2035b07553e6dc79c1cee19d4e27e1f2ff19a43d512a19505fb8dc')
b2sums=('f63bab8dd7d9da0fa0b4ae4fb1e4e4b4a052d1ac49b404713528372472e8f7e2a280672c9fbbd68111325c11778ee908024de5af1576ae81444169df71fa92cf')

build() {
  local cmake_options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_BUILD_TYPE=None
    -W no-dev
    -B build
    -S $pkgname-$pkgver/build
  )
  cmake "${cmake_options[@]}"
  cmake --build build --verbose
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/readme.md -t "$pkgdir/usr/share/doc/$pkgname/"
  mv -v "$pkgdir/usr/"{CHANGELOG.txt,README.html} "$pkgdir/usr/share/doc/$pkgname/"
  mv -v "$pkgdir/usr/share/$pkgname/doc/"*.pdf "$pkgdir/usr/share/doc/$pkgname/"
  rmdir -v "$pkgdir/usr/share/$pkgname/doc/"
}
